<?php

    class MLogin extends Model {

        function MLogin()
        {
            parent :: Model();
        }

        function checkLogin($user, $pwd)
        {
            $this->db->select('u_id, user_name');
            $this->db->where('user_name', $user);
            $this->db->where('password', $pwd);
            $query = $this->db->get('member');

            if($query->num_rows() > 0) {
                $row = $query->row_array();
                $_SESSION['userid'] = $row['u_id'];
                $_SESSION['username'] = $row['user_name'];
            } else {
                $this->session->set_flashdata('error', 'Sorry, your username or password is incorrect!');
            }

        }

    }